package com.bq.gametrade.bean;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;

/**
 * Created by Feel on 2017/1/6.
 */

public class RedEnvelopeListDetails implements Serializable,Parcelable {

    public String id;
    public String ctime;

    public String send_user;

    public String revice_user;

    public String send_uname;

    public String revice_uname;

    public String send_img;

    public String revice_img;
    //0 余额  1：鱼券
    public String type;

    public String num;

    //红包状态 0 未领取   1领取  2超时
    public String m_status;
    //留言
    public String title;


    @Override
    public String toString() {
        return "RedEnvelopeListDetails [id=" + id + ",ctime=" + ctime + ", send_user=" + send_user + ", revice_user=" + revice_user +
                ", send_uname=" + send_uname +", revice_uname=" + revice_uname +", send_img=" + send_img +", revice_img=" + revice_img +", type=" + type +
                ", num=" + num +", m_status=" + m_status +", title=" + title +"]";
    }

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(ctime);
        dest.writeString(send_user);
        dest.writeString(revice_user);
        dest.writeString(send_uname);
        dest.writeString(revice_uname);
        dest.writeString(send_img);
        dest.writeString(revice_img);
        dest.writeString(type);
        dest.writeString(num);
        dest.writeString(m_status);
        dest.writeString(title);


    }

    // 1.必须实现Parcelable.Creator接口,否则在获取Person数据的时候，会报错，如下：
    // android.os.BadParcelableException:
    // Parcelable protocol requires a Parcelable.Creator object called  CREATOR on class com.um.demo.Person
    // 2.这个接口实现了从Percel容器读取Person数据，并返回Person对象给逻辑层使用
    // 3.实现Parcelable.Creator接口对象名必须为CREATOR，不如同样会报错上面所提到的错；
    // 4.在读取Parcel容器里的数据事，必须按成员变量声明的顺序读取数据，不然会出现获取数据出错
    // 5.反序列化对象
    public static final Parcelable.Creator<RedEnvelopeListDetails> CREATOR = new Creator(){

        @Override
        public RedEnvelopeListDetails createFromParcel(Parcel source) {
            // TODO Auto-generated method stub
            // 必须按成员变量声明的顺序读取数据，不然会出现获取数据出错
            RedEnvelopeListDetails p = new RedEnvelopeListDetails();
            p.id = source.readString();
            p.ctime = source.readString();
            p.send_user = source.readString();
            p.revice_user = source.readString();
            p.send_uname = source.readString();
            p.revice_uname = source.readString();
            p.send_img = source.readString();
            p.revice_img = source.readString();
            p.type = source.readString();
            p.num = source.readString();
            p.m_status = source.readString();
            p.title = source.readString();

            return p;
        }

        @Override
        public RedEnvelopeListDetails[] newArray(int size) {
            // TODO Auto-generated method stub
            return new RedEnvelopeListDetails[size];
        }
    };

}
